#ifndef LOGGER_MANAGER_H
#define LOGGER_MANAGER_H

#include "log_config.h"
#include "./detail/log_appender.h"
#include "./detail/log_monitor.h"
#include "./detail/file_appender_config.h"

#include <map>
#include <vector>
#include <memory>

namespace vpm
{
	namespace log 
	{
		class Logger; 

		class LoggerManager
		{
			typedef std::vector<LogAppender* > LogAppenders; 
		public:		
			
			static LoggerManager & instance(); 

			Logger * get_logger(const std::string & module);

			int start_logger();	

			void stop_logger(); 

			void set_level(const std::string & module, LogConfig::LogLevel lv, bool flag/* on/Off */ ); 

			void add_file_appender(boost::shared_ptr<FileAppenderConfig>  cfg); 

#ifdef LOGGER_NET_APPENDER

			void add_tcp_appender( int port ,const std::string & ipaddr ="0.0.0.0"); 

			void add_udp_appender( int port ,const std::string & ipaddr ="127.0.0.1");
#endif //

		private:
			LoggerManager();	

			friend class Logger; 

			void register_logger(const std::string & module, Logger * ); 

			void unregister_logger(const std::string & module); 

		private:
			std::map<std::string, Logger * > m_loggers; 
			static LoggerManager  *m_loggerManager; 
			LogAppenders m_logAppenders; 
		};
	}
}
#endif // 

